import java.rmi.Remote;
import java.rmi.RemoteException;
import java.rmi.server.UnicastRemoteObject;
import java.rmi.RMISecurityManager;

import net.jini.lookup.entry.Name;
import net.jini.core.lookup.ServiceRegistrar;
import net.jini.core.lookup.ServiceItem;
import net.jini.core.discovery.LookupLocator;
import net.jini.core.entry.Entry;
import net.jini.core.lease.Lease;

public class RealPrinterDriver extends UnicastRemoteObject implements PrintService {

	public void printBitmap(byte[] b) throws RemoteException {
		System.out.println("Printing job");
	}
	
	public RealPrinterDriver() throws RemoteException {
		super ();
	}
	
	public static void main (String[] args) {
		try {
			System.setSecurityManager (new RMISecurityManager ());
			
			ServiceItem serviceItem = new ServiceItem(null, new RealPrinterDriver(), null);

			LookupLocator lookup = new LookupLocator ("jini://localhost");
			ServiceRegistrar registrar  = lookup.getRegistrar();
			registrar.register(serviceItem, Lease.FOREVER);

			System.out.println("Printer online");

		} catch (Exception e)
		{
			e.printStackTrace();
		}
	}

} 